package com.kechen.client.fegin;

import com.kechen.client.pojo.MyFallBack;
import com.kechen.client.pojo.User;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

// 如果使用第一种Fallback方式， 使用该注解
@FeignClient(value="QF-SEARCH",fallback = MyFallBack.class)
//@FeignClient(value = "QF-SEARCH",fallbackFactory = MyFallBackFactory.class)  如果使用第二种Fallback方式， 添加这个注解
@RestController
public interface Myfegin {
    /**
    * 搜索feign接口方法, 建议复制被调用服务方法, 就是search模块中controller中的方法,直接复制过来
    * 不要手写, 容易写错
    * @return
    */
    @RequestMapping("/search")
    public String index() ;

    // 传递参数的情况
    @RequestMapping(value = "/user/{id}",method = RequestMethod.GET)
    User findById(@PathVariable(value = "id") Integer id);

    @RequestMapping(value = "/getUser",method = RequestMethod.GET)
    User getUser(@RequestParam(value = "id") Integer id, @RequestParam(value = "name") String name);

    @RequestMapping(value = "/save",method = RequestMethod.POST)
    User save(@RequestBody User customer);
}
